package com.demo.order.elasticjob.job;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TestJob2 implements SimpleJob {
    @Override
    public void execute(ShardingContext shardingContext) {
        int shardingItem = shardingContext.getShardingItem();
        String jobParameter = shardingContext.getJobParameter();
        String jobName = shardingContext.getJobName();
        String shardingParameter = shardingContext.getShardingParameter();
        switch (shardingItem) {
            case 0:
                log.info("Job：{}，分片任务0正在执行...公有参数：{}，私有参数：{}",jobName,jobParameter,shardingParameter);
                break;
            case 1:
                log.info("Job：{}，分片任务1正在执行...公有参数：{}，私有参数：{}",jobName,jobParameter,shardingParameter);
                break;
            case 2:
                log.info("Job：{}，分片任务2正在执行...公有参数：{}，私有参数：{}",jobName,jobParameter,shardingParameter);
                break;
            case 3:
                log.info("Job：{}，分片任务3正在执行...公有参数：{}，私有参数：{}",jobName,jobParameter,shardingParameter);
                break;
            case 4:
                log.info("Job：{}，分片任务4正在执行...公有参数：{}，私有参数：{}",jobName,jobParameter,shardingParameter);
                break;
            default:
                log.info("Job：{}，默认任务正在执行...公有参数：{}，私有参数：{}",jobName,jobParameter,shardingParameter);
                break;
        }
    }
}
